<?php

namespace App\Models\Products;

use App\Models\Concerns\ScopeFilterable;
use Illuminate\Database\Eloquent\Model;

/**
 * Class ProductSpecial
 *
 * @property string price - 特价价格
 *
 * @package App\Models\Products
 */
class ProductSpecial extends Model
{
    const DEFAULT_PRODUCT_SPECIAL_PRICE = 0;
    const PRODUCT_SPECIAL_NUM = 1; // 商品特价类型数目。

    protected $table = 'product_special';
    protected $guarded = [];

    protected $primaryKey = 'product_special_id';

    use ScopeFilterable;
    /**
     * @param Product $product
     * @return ProductSpecial|Model|\Illuminate\Database\Eloquent\Relations\HasMany|null|object
     */
    public static function getProductSpecial(Product $product)
    {
        $product_special = $product->productSpecials->first();

        return $product_special;
    }
}
